<?php

class SnapupController extends BaseController
{
	
	/**
	 * 抢购秒杀管理
	 */
	public function actionAdmin()
	{
		$model=new ProTuan('search');
		$model->unsetAttributes();  //清空属性
		$model->zpt_type = 2; // 1:团购2:秒杀3:限量抢购',
		$model->zpt_close = array(1,2); //状态不为删除
		if(isset($_GET['ProTuan']))
			$model->attributes=$_GET['ProTuan'];

		$this->render('admin',array(
			'model'=>$model,
		));
	}

	/**
	 * 单条批量删除 抢购秒杀
	 */
	public function actionDelete(){
		//操作ID号格式处理
		if(isset($_GET['id'])){
			$id = $_GET['id'];
		}elseif(isset($_POST['ids'])){
			$id =$_POST['ids'];
		}else{
			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
		}
		$id = is_array($id)?join(',',$id):(int)$id;
		//处理条件
		$criteria=new CDbCriteria;
		$criteria->addCondition("zpt_id in ($id)");
		//修改内容
		$set = array('zpt_close'=>'3');
		//执行操作
		if(ProTuan::model()->updateAll($set,$criteria)){
			//成功跳转
			$this->redirect(Yii::app()->request->urlReferrer);
		}
	}

}